package wcg;

import ikelib.drawTools;

import javax.swing.JPanel;

import java.awt.Component;
import java.awt.FontMetrics;
import java.awt.Frame;
import java.awt.BorderLayout;
import javax.swing.JDialog;
import javax.swing.JButton;
import java.awt.Rectangle;
import javax.swing.JProgressBar;
import javax.swing.JTextField;
import java.awt.Dimension;
import javax.swing.JLabel;

public class ProgressDialog extends JDialog {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JButton jButtonCancel = null;

	private JProgressBar jProgressBarMain = null;
	private JTextField jTextField1 = null;
	private JTextField jTextField2 = null;
	private boolean canceled = false;
	private JProgressBar jProgressBarAll = null;
	private JLabel jLabelMemoryRemain = null;
	private JProgressBar jProgressBarMemoryUsing = null;
		
	public JProgressBar getProgressBarMemory() {
		return jProgressBarMemoryUsing;
	}
	public JProgressBar getProgressBar2() {
		return jProgressBarMain;
	}
	public JProgressBar getProgressBar1() {
		return jProgressBarAll;
	}
	public String getText1() {
		return jTextField1.getText();
	}

	public String getText2() {
		return jTextField2.getText();
	}

	public boolean isCanceled() {
		return canceled;
	}

	public void setText1(String text) {
		text = drawTools.trancateString(text,(Component)jTextField1);
		this.jTextField1.setText(text);
	}

	public void setText2(String text) {
		this.jTextField2.setText(text);
	}
	public void reset(){
		jProgressBarMain.setValue(0);
		jProgressBarAll.setValue(0);
		jTextField1.setText("");
		jTextField2.setText("");
		canceled = false;
	}


	/**
	 * @param owner
	 */
	public ProgressDialog(Frame owner) {
		super(owner,"Reading file",true);
		initialize();
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(308, 261);
		this.setContentPane(getJContentPane());
	}
	public JLabel getLabel1(){
		return jLabelMemoryRemain;
	}
	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLabelMemoryRemain = new JLabel();
			jLabelMemoryRemain.setBounds(new Rectangle(8, 13, 81, 19));  // Generated
			jLabelMemoryRemain.setText("Memory free");  // Generated
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJButtonCancel(), null);
			jContentPane.add(getJProgressBarMain(), null);
			jContentPane.add(getJTextField1(), null);
			jContentPane.add(getJTextField2(), null);
			jContentPane.add(getJProgressBarAll(), null);  // Generated
			jContentPane.add(jLabelMemoryRemain, null);  // Generated
			jContentPane.add(getJProgressBarMemoryUsing(), null);  // Generated
			jContentPane.add(getProgressBar2(), null);  // Generated
		}
		return jContentPane;
	}

	/**
	 * This method initializes jButtonCancel	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getJButtonCancel() {
		if (jButtonCancel == null) {
			jButtonCancel = new JButton();
			jButtonCancel.setBounds(new Rectangle(92, 187, 95, 31));
			jButtonCancel.setText("Cancel");
			jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					canceled=true;
					setVisible(false);
				}
			});
		}
		return jButtonCancel;
	}

	/**
	 * This method initializes jProgressBarMain	
	 * 	
	 * @return javax.swing.JProgressBar	
	 */
	private JProgressBar getJProgressBarMain() {
		if (jProgressBarMain == null) {
			jProgressBarMain = new JProgressBar();
			jProgressBarMain.setStringPainted(true);
			jProgressBarMain.setBounds(new Rectangle(9, 149, 272, 25));  // Generated
		}
		return jProgressBarMain;
	}

	/**
	 * This method initializes jTextField1	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField1() {
		if (jTextField1 == null) {
			jTextField1 = new JTextField();
			jTextField1.setBounds(new Rectangle(8, 52, 272, 25));
			jTextField1.setEditable(false);
		}
		return jTextField1;
	}

	/**
	 * This method initializes jTextField2	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField2() {
		if (jTextField2 == null) {
			jTextField2 = new JTextField();
			jTextField2.setBounds(new Rectangle(8, 83, 272, 25));
			jTextField2.setEditable(false);
		}
		return jTextField2;
	}

	/**
	 * This method initializes jProgressBarAll	
	 * 	
	 * @return javax.swing.JProgressBar	
	 */
	private JProgressBar getJProgressBarAll() {
		if (jProgressBarAll == null) {
			jProgressBarAll = new JProgressBar();
			jProgressBarAll.setBounds(new Rectangle(8, 114, 272, 25));  // Generated
			jProgressBarAll.setStringPainted(true);
		}
		return jProgressBarAll;
	}
	/**
	 * This method initializes jProgressBarMemoryUsing	
	 * 	
	 * @return javax.swing.JProgressBar	
	 */
	private JProgressBar getJProgressBarMemoryUsing() {
		if (jProgressBarMemoryUsing == null) {
			jProgressBarMemoryUsing = new JProgressBar();
			jProgressBarMemoryUsing.setBounds(new Rectangle(100, 14, 183, 20)); 
			jProgressBarMemoryUsing.setStringPainted(true);
		}
		return jProgressBarMemoryUsing;
	}

}  //  @jve:decl-index=0:visual-constraint="10,10"
